﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Text;

namespace Admx_Generator
{
    public class TextBoxPresentation : IPresentationElement
    {
        public TextBoxPresentation(string refId, string label)
        {
            this.RefId = refId;
            this.Label = label;
            this.DefaultValue = String.Empty;
        }

        private string RefId { get; set; }
        private string Label { get; set; }
        public string DefaultValue { get; set; }

        public void Save(XmlWriter xmlWriter)
        {
            // textBox
            xmlWriter.WriteStartElement("textBox");
            xmlWriter.WriteAttributeString("refId", this.RefId);
            // label
            xmlWriter.WriteStartElement("label");
            xmlWriter.WriteString(this.Label);
            xmlWriter.WriteEndElement(); // label
            if (!String.IsNullOrEmpty(this.DefaultValue))
            {
                // defaultValue
                xmlWriter.WriteStartElement("defaultValue");
                xmlWriter.WriteString(this.DefaultValue);
                xmlWriter.WriteEndElement(); // defaultValue
            }
            xmlWriter.WriteEndElement(); // textBox
        }
    }
}
